<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class Person {
      // 公有属性
      name;
      sex;
      // 私有属性
      #weight;
      #height;

      constructor(name, sex, weight, height) {
        this.name = name;
        this.sex = sex;
        this.#weight = weight;
        this.#height = height;
      }

      intro() {
        console.log(p.name);
        console.log(p.sex);
        console.log(p.#weight);    // 私有属性不能在外部直接调用
        console.log(p.#height);

      }

    }
    // 实例化对象
    let p = new Person('小红', '女', 80, 180);

    console.log(p.name);
    console.log(p.sex);
    // console.log(p.#weight);    // 私有属性不能在外部直接调用
    // console.log(p.#height);

    p.intro()

  </script>
</body>

</html>